package org.ruizhijie.config;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

public class SystemConfig {
	public static void init(Properties pro) {
		baudRate = Integer.parseInt(pro.get("baudRate") + "");
		dataBits = Integer.parseInt(pro.get("dataBits") + "");
		stopBits = Integer.parseInt(pro.get("stopBits") + "");
		parity = Integer.parseInt(pro.get("parity") + "");
		tcpServerPort = Integer.parseInt(pro.get("tcpServerPort") + "");
		
		for (int i=0;i<100;i++) {
			String nn = pro.get("in["+i+"]")+"";
			String mm = pro.get("out["+i+"]")+"";
			if ("null".equals(nn)||"null".equals(mm))continue;
			
			in.add(nn);
			out.add(mm);
		}
		
		if (in.size()<=0||out.size()<=0||in.size()!=out.size()) {
			System.err.println("输入输出串口设置错误!");
		}
		
		inPort = Integer.parseInt(pro.get("inPort") + "");
		outPort = Integer.parseInt(pro.get("outPort") + "");
		serverPort = Integer.parseInt(pro.get("serverPort") + "");
		
		inHost = pro.getProperty("inHost");
		outHost = pro.getProperty("outHost");
		serverHost = pro.getProperty("serverHost");
	}

	public static List<String> in = new ArrayList<String>();
	public static List<String> out = new ArrayList<String>();
	public static int baudRate;
	public static int dataBits;
	public static int stopBits;
	public static int parity;
	public static int tcpServerPort;
	

	public static int inPort;
	public static int outPort;
	public static int serverPort;
	public static String inHost;
	public static String outHost;
	public static String serverHost;
}
